package core

class LegalIdentifierController {

    static layout = 'country'
	
	def createLeg()
	{
			
	}
	def update() {
		def legalidentifier =  LegalIdentifier.get(params.long('id'))
		legalidentifier.properties = params
		if(legalidentifier.save()) {
			flash.notice = "LegalIdentifier: ${legalidentifier.name} was updated"
			redirect action:'index'
		}
		else {
			flash.error = "LegalIdentifier:  failed to be update"
			render(view:'editDoc',model:[legalidentifier: legalidentifier])
		}
	}
	
	def editLeg()
	{
		[legalidentifier: LegalIdentifier.get(params.long('id'))]	
	}
	
	def deleteLeg()
	{
	def legalidentifier =  LegalIdentifier.get(params.id)
	   
		legalidentifier.delete()
		redirect(action:'index')	
	}
	
	def save() {
		def legalidentifier = new LegalIdentifier(params)
		
		if (legalidentifier.save()) {
			flash.notice = "LegalIdentifier ${legalidentifier.name}: is saved successfuly"
			redirect(action:'index')
		} else {
			flash.error = "LegalIdentifier ${legalidentifier.name}: Failed to save"
			render view:'createLeg', model:[legalidentifier:legalidentifier]
		}
	}

    def index() { 
		
		def max = params.long('max')?:10
		def start = params.long('start')?:0
		[LegalIdentifiers:LegalIdentifier.list(max: max, offset:start ),max:max, start:start ]
		
		
	}
	
//	def documents() {
//		def map = [ documents: DocumentType.list() ]
//		render(view: "show", model: map)
//	}
	
	def show() {
		
				[LegalIdentifier: LegalIdentifier.get(params.long('id'))]
			}
}
